if (previous_save[0] != '\0' && fexist(fconv(previous_save))) {
rename(fconv(previous_save), fconv(save));
if (fexist(fconv(save))) {
found = 1;
if ((opt->debug>1) && (opt->log!=NULL)) {
fspc(opt->log,"debug"); fprintf(opt->log,"File '%s' has been renamed since last mirror to '%s' ; applying changes"LF, previous_save, save); test_flush;
}
} else {
if ((opt->debug>0) && (opt->log!=NULL)) {
fspc(opt->log,"error"); fprintf(opt->log,"Could not rename '%s' to '%s' ; will have to retransfer it"LF, previous_save, save); test_flush;
}
}
}
}
if (!found) {
#if HTS_FAST_CACHE
hash_pos_return=0;
#else
a=NULL;
#endif
// dΘvalider car non prΘsent sur disque dans structure originale!!!
// sinon, le fichier est ok α priori, mais on renverra un if-modified-since pour
// en Ωtre s√r
if (opt->norecatch) { // tester norecatch
if (!fexist(fconv(save))) { // fichier existe pas mais dΘclarΘ: on l'a effacΘ
FILE* fp=fopen(fconv(save),"wb");
if (fp) fclose(fp);
if (opt->log!=NULL) {
fspc(opt->log,"warning"); fprintf(opt->log,"File must have been erased by user, ignoring: %s%s"LF,back[p].url_adr,back[p].url_fil); test_flush;
}
}
}
}
} // fsize() <= 0
}
}
}
//
} else
#if HTS_FAST_CACHE
hash_pos_return=0;
#else
a=NULL;
#endif
// Existe pas en cache, ou bien pas de cache prΘsent
#if HTS_FAST_CACHE
if (hash_pos_return) { // OK existe en cache (et donnΘes aussi)!
#else
if (a!=NULL) { // OK existe en cache (et donnΘes aussi)!
#endif
if (cache->type==1) { // cache prioritaire (pas de test if-modified..)
// dans ce cas on peut Θgalement lire des rΘponses cachΘes comme 404,302...
// transform 406 into 200 ; we'll catch embedded links inside the choice page
if (back[i].r.statuscode==406) { // 'Not Acceptable'
back[i].r.statuscode=200;
}
// 'do not erase already downloaded file'
// on an updated file
// with an error : consider a 304 error
if (!opt->delete_old) {
if (HTTP_IS_ERROR(back[i].r.statuscode) && back[i].is_update && !back[i].testmode) {
if (back[i].url_sav[0] && fexist(back[i].url_sav)) {
if ((opt->debug>1) && (opt->log!=NULL)) {
fspc(opt->log,"debug"); fprintf(opt->log,"Error ignored %d (%s) because of 'no purge' option for %s%s"LF,back[i].r.statuscode,back[i].r.msg,back[i].url_adr,back[i].url_fil); test_flush;
fspc(opt->errlog,"warning"); fprintf(opt->errlog,"File seems complete (same size), but there was a cache read error: %s%s"LF,back[i].url_adr,back[i].url_fil); test_flush;
}
}
if (r.adr) {
freet(r.adr);
r.adr = NULL;
}
}
}
}
// Various hacks to limit re-transfers when updating a mirror
// Detect already downloaded file (with another browser, for example)
if (opt->sizehack) {
if (!back[i].is_update) { // mise α jour
if (back[i].r.statuscode==200 && !back[i].testmode) { // 'OK'
if (!is_hypertext_mime(back[i].r.contenttype, back[i].url_fil)) { // not HTML
if (strnotempty(back[i].url_sav)) { // target found